package com.bluno.view.obj;

import com.bluno.Util;
import com.bluno.view.Resourcer;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;

public class EnemyHand extends SceneObj{

	private Bitmap facedDownImage;
	private int nCards;
	private char pos;
	private int xi;
	private int yi;
	public EnemyHand(int nCards, char pos)
	{
		this.nCards = nCards;
		this.pos = pos;
		int x = 0,y = 0;
		xi = 0;
		yi = 0;
		switch (pos)
		{
			case 'c':
				x = 0;
				y = 5;
				facedDownImage = Resourcer.imageMap.get("facedDownImage0");
				xi = 1;
				yi = 0;
				break;
			case 'd':
				x = 5;
				y = -30;
				facedDownImage = Resourcer.imageMap.get("facedDownImage1");
				xi = 0;
				yi = 1;
			break;
			case 'b':
				facedDownImage = Resourcer.imageMap.get("facedDownImage1");
				x = Util.SCREEN_WIDTH - 5 - facedDownImage.getWidth();
				y = -30;
				xi = 0;
				yi = 1;
			break;
		}
		super.setX(x);
		super.setY(y);
	}
	@Override
	public void draw(Canvas canvas, Paint paint) {

	
        int d = 0;
        if(nCards != 0)
            d =  (200)/(nCards);
        if(d > 40)
            d = 40;
        
        int init;
        if(xi == 1)
        	init = Util.SCREEN_MIDDLE_X - (d*(nCards))/2;
        else
        	init = Util.SCREEN_MIDDLE_Y - (d*(nCards))/2;
        
		for(int i = 0; i < this.nCards; ++i)
		{
			canvas.drawBitmap(facedDownImage,super.getX() + (init + d*i)*xi, super.getY() + (init + d*i)*yi ,paint);
		}
	}

	@Override
	public void update() {
		
	}
	public Bitmap getFacedDownImage() {
		return facedDownImage;
	}
	public void setFacedDownImage(Bitmap facedDownImage) {
		this.facedDownImage = facedDownImage;
	}
	public char getPos() {
		return pos;
	}
	public void setPos(char pos) {
		this.pos = pos;
	}
	public int getnCards() {
		return nCards;
	}
	public void setnCards(int nCards) {
		this.nCards = nCards;
	}  
	

}
